﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;
using Entity;

namespace DataControls
{
    public class KHOA_Data
    {
        KHOA khoa = new KHOA();
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        public void khoa_Combobox(ComboBox cb)
        {
            String excuteString = "SELECT * FROM KHOA";
            dataBaseAccess.addto_Combobox(cb, excuteString);
        }

        public Boolean kiemtraMaKhoa_Lop(String makhoa)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM LOPHOC WHERE MAKHOA='" + makhoa + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else return false;
        }

        public Boolean kiemtraMaKhoa_GV(String makhoa)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM GIAOVIEN WHERE MAKHOA='" + makhoa + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else return false;
        }

        public Boolean kiemtra_MaKhoa(String makhoa)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM KHOA WHERE MAKHOA='" + makhoa + "'";
             i = dataBaseAccess.Test(excuteString);
            if(i> 0)
                return true;
            else return false;
        }

        public Boolean kiemtra_TenKhoa(String tenkhoa)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM KHOA WHERE TENKHOA='" + tenkhoa + "'";
             i = dataBaseAccess.Test(excuteString);
             if (i > 0)
                 return true;
             else 
                 return false;
        }
    }
}
